import { createSlice } from "@reduxjs/toolkit";
import { createAsyncThunk } from "@reduxjs/toolkit";
import * as Api from "../Api/https";

const initialState = {
  shopList: [],
  shopDetail: [],
};

const todosSlice = createSlice({
  name: "todos",
  initialState,
  reducers: {
    getShopData(state, action) {
      // 这里可以添加处理逻辑
      state.shopList = action.payload;
    },
  },
});

export default todosSlice.reducer;
export const actions = todosSlice.actions;

// 获取数据
export let r_getShopData = createAsyncThunk("getShopData", async (_, store) => {
  const res = await Api.getTableData()
  store.dispatch(actions.getShopData(res));
});